﻿#if WINRT
using Windows.UI;
#else
using System.Windows.Media;
#endif

namespace Esponce.Common
{
	internal static class ColorExtensions
	{
		/// <summary>
		/// Gets a hex string that represents a color, e.g. "#fff500" for yellow.
		/// </summary>
		/// <param name="color">Color</param>
		/// <param name="alpha">Append alpha channel ordered as ARGB.</param>
		/// <returns>Returns #RRGGBB or #AARRGGBB string.</returns>
		public static string ToHexString(this Color color, bool alpha = false)
		{
			string hex = null;
			if (alpha)
			{
				hex = string.Format("#{0:x2}{1:x2}{2:x2}{3:x2}", color.A, color.R, color.G, color.B);
			}
			else
			{
				hex = string.Format("#{0:x2}{1:x2}{2:x2}", color.R, color.G, color.B);
			}
			return hex;
		}
	}
}
